package cn.iocoder.yudao.module.infra.enums.security;

import com.fasterxml.jackson.annotation.JsonCreator;
import com.fasterxml.jackson.annotation.JsonValue;

/**
 * 安全模式
 */
public enum UriSecurityModeEnum {
    URI_WHITE_LIST("URI_WHITE_LIST", "uri白名单"),
    URI_BLACK_LIST("URI_BLACK_LIST", "uri黑名单");

    private final String code;
    private final String description;

    UriSecurityModeEnum(String code, String description) {
        this.code = code;
        this.description = description;
    }

    // 获取代码
    public String getCode() {
        return code;
    }

    // 获取描述
    public String getDescription() {
        return description;
    }

    // Jackson 反序列化方法
    @JsonCreator
    public static UriSecurityModeEnum fromCode(String code) {
        for (UriSecurityModeEnum status : UriSecurityModeEnum.values()) {
            if (status.code.equals(code)) {
                return status;
            }
        }
        throw new IllegalArgumentException("Invalid reconciled amount status code: " + code);
    }

    // Jackson 序列化方法
    @JsonValue
    public String getCodeValue() {
        return code;
    }

    @Override
    public String toString() {
        return description;
    }
}
